<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%// Grab the username and emp_id form of the user from session
String uname=(String)session.getAttribute("userName");
String emp_id=(String)session.getAttribute("emp_id");
int ei=Integer.parseInt(emp_id);
%>
<h1>Notice from admin</h1>
<%
String query="select notice from employee where emp_id='"+ei+"'";
Connection db_conn = null;
Statement statement = null;
PreparedStatement pstmt;
ResultSet rs;
try{
Class.forName("com.mysql.jdbc.Driver");
String url= "jdbc:mysql://localhost:3306/db";
db_conn = DriverManager.getConnection( url,"root", "root" );
statement = db_conn.createStatement();
rs=statement.executeQuery(query);
while (rs.next()) { // parse the results
out.print("<p>"+rs.getString("notice")+"</p>");
}
db_conn.close();
} catch(SQLException e){
e.printStackTrace();
out.println("sql not found");
out.println(e);
} catch(ClassNotFoundException e){
e.printStackTrace();
out.println(e);
}
%>